﻿<%@ Page Language="C#" MasterPageFile="~/provider/Provider.master" AutoEventWireup="true"
    CodeFile="ResetPassword.aspx.cs" Inherits="Provider_ResetPassword" Title="Provider - Reset Password - CompareXpress" %>

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
    <table width="100%" border="0" cellpadding="0" cellspacing="0">
        <tr>
            <td width="30%">
                <h1>
                    Reset Password</h1>
            </td>
            <td width="70%">
                &nbsp;
                <asp:Label ID="lblAutoKey" Visible="false" runat="server"></asp:Label>
                <asp:Label ID="lblGUID" Visible="false" runat="server"></asp:Label>
            </td>
        </tr>
        <tr>
            <td>
                Email
            </td>
            <td>
                <asp:Label ID="lblEmail" runat="server"></asp:Label>
            </td>
        </tr>
        <tr>
            <td>
                &nbsp;
            </td>
            <td>
                &nbsp;
            </td>
        </tr>
        <tr>
            <td>
                Enter New Password
            </td>
            <td>
                <asp:TextBox ID="txtNewPassword" runat="server" MaxLength="20" TextMode="Password"></asp:TextBox>
                <asp:RequiredFieldValidator ID="rfvNewPassword" runat="server" ControlToValidate="txtNewPassword"
                    Display="Dynamic" ErrorMessage="Require new password." Text="Require new password."
                    ValidationGroup="customer">
                </asp:RequiredFieldValidator>
                <asp:RegularExpressionValidator ID="revNewPassword" runat="server" ControlToValidate="txtNewPassword"
                    ValidationExpression="^\w*(?=\w*\d{2})(?=\w*[a-z]{2})(?=\w*[A-Z]{2})\w{8,20}$"
                    Display="Dynamic" ErrorMessage="Enter valid password.(two upper case, two lower case, two digits and length 8 characters.)"
                    ValidationGroup="customer" />
                <%--<asp:CustomValidator ID="csvNewPassword" runat="server" ClientValidationFunction="CheckPasswordLength"
                    ControlToValidate="txtNewPassword" Display="Dynamic" ErrorMessage="Password length should be at least 6."
                    ValidationGroup="customer">*</asp:CustomValidator>--%>
            </td>
        </tr>
        <tr>
            <td>
                &nbsp;
            </td>
            <td>
                &nbsp;
            </td>
        </tr>
        <tr>
            <td>
                Confirm New Password
            </td>
            <td>
                <asp:TextBox ID="txtRetypeNewPassword" runat="server" MaxLength="20" TextMode="Password"></asp:TextBox>
                <asp:RequiredFieldValidator ID="rfvRetypePassword" runat="server" ValidationGroup="customer"
                    ErrorMessage="Required confirm password." Text="Required confirm password." Display="Dynamic"
                    ControlToValidate="txtRetypeNewPassword"></asp:RequiredFieldValidator>
                <asp:CompareValidator ID="csvRetypePassword" runat="server" Display="Dynamic" ValidationGroup="customer"
                    ErrorMessage="New and confirm password should be same." Text="New and confirm password should be same."
                    ControlToValidate="txtRetypeNewPassword" ControlToCompare="txtNewPassword"></asp:CompareValidator>
            </td>
        </tr>
        <tr>
            <td>
                &nbsp;
            </td>
            <td>
                <asp:Label ID="lblMessage" ForeColor="Red" runat="server"></asp:Label>
            </td>
        </tr>
        <tr>
            <td>
                &nbsp;
            </td>
            <td>
                <asp:Button ID="btnSubmit" runat="server" Text="Set Password" OnClick="btnSubmit_Click"
                    ValidationGroup="customer" />
            </td>
        </tr>
    </table>

    <script type="text/javascript">
        function CheckPasswordLength(source, arguments) {
            //var corglen = arguments.Value;
            var cval = arguments.Value;
            var bValid = true;
            var chList = new Array(20);
            var ctrlsource = document.getElementById(source.id);

            //alert("ORG LEN : " + corglen.length + " AFTER : " + cval.length);
            if (cval.indexOf(' ') != -1 || cval.indexOf('\'') != -1
                        || cval.indexOf('\"') != -1 || cval.indexOf('~') != -1) {
                if (ctrlsource.textContent) {
                    ctrlsource.textContent = "Password include invalid character or space!";
                }
                else {
                    ctrlsource.innerText = "Password include invalid character or space!";
                }

                ctrlsource.errormessage = "Password include invalid character or space!";
                bValid = false;
            }
            else if (cval.length < 6) {
                //ctrlsource.innerText = "Password length should be at least 6";
                if (ctrlsource.textContent) {
                    ctrlsource.textContent = "Password length should be at least 6";
                }
                else {
                    ctrlsource.innerText = "Password length should be at least 6";
                }

                ctrlsource.errormessage = "Password length should be at least 6";
                bValid = false;
            }
            else if (cval.length > 20) {
                bValid = false;
                //ctrlsource.innerText = "Password length should not be over 20!";
                if (ctrlsource.textContent) {
                    ctrlsource.textContent = "Password length should not be over 20!";
                }
                else {
                    ctrlsource.innerText = "Password length should not be over 20!";
                }
                ctrlsource.errormessage = "Password length should not be over 20!";
            }
            else {
                bValid = true;
            }
            //alert(cval);
            //if (isNaN(cval)){
            //    bValid = false;
            //} 


            //alert(bValid);
            arguments.IsValid = bValid;
            return;
        }
    </script>

</asp:Content>
